using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace QLNS.Data
{
    class HeSoLuongData
    {
        Services m_Ds = new Services();

        public DataTable DanhSachHeSoLuong()
        {
            OleDbCommand cmd = new OleDbCommand("SELECT * FROM HESOLUONG");
            m_Ds.Load(cmd);
            return m_Ds;
        }        
        public DataTable TimMa(String ma)
        {
            OleDbCommand cmd = new OleDbCommand("SELECT * FROM HESOLUONG WHERE ID =" + ma);
            cmd.Parameters.Add("ma", OleDbType.VarChar).Value = ma;
            m_Ds.Load(cmd);

            return m_Ds;
        }
        public DataTable TimHeSo(double heso)
        {
            OleDbCommand cmd = new OleDbCommand("SELECT * FROM HESOLUONG WHERE HeSoLuong =" + heso);
            cmd.Parameters.Add("heso", OleDbType.Double).Value = heso;
            m_Ds.Load(cmd);

            return m_Ds;
        }
        public DataTable LayHeSoLuong(string ngach, string bac)
        {
            OleDbCommand cmd = new OleDbCommand("SELECT * FROM HESOLUONG WHERE ngach = '" + ngach+"' and bacluong = '"+bac+"'");
            cmd.Parameters.Add("ngach", OleDbType.VarChar).Value = ngach;
            cmd.Parameters.Add("bac", OleDbType.VarChar).Value = bac;
            m_Ds.Load(cmd);

            return m_Ds;
        }
        public DataRow NewRow()
        {
            return m_Ds.NewRow();
        }
        public void Add(DataRow row)
        {
            m_Ds.Rows.Add(row);
        }
        public bool Save()
        {
            return m_Ds.ExecuteNoneQuery() > 0;
        }

    }
}
